package top.codecrab.springcloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author codecrab
 * @since 2021年05月18日 8:16
 */
@Configuration
public class GatewayConfig {

    @Bean
    public RouteLocator customizeRouteLocator1(RouteLocatorBuilder routeLocatorBuilder) {
        return routeLocatorBuilder.routes().route(
                "route_to_guonei",
                r -> r.path("/guonei")
                        .uri("http://news.baidu.com/guonei")
        ).build();
    }

    @Bean
    public RouteLocator customizeRouteLocator2(RouteLocatorBuilder routeLocatorBuilder) {
        return routeLocatorBuilder.routes().route(
                "route_to_guoji",
                r -> r.path("/guoji")
                        .uri("http://news.baidu.com/guoji")
        ).build();
    }

}
